package com.peas.platform.module.icims.base.dict.domain.impl;

import com.peas.platform.framework.mybatisplus.domain.BaseDomainImpl;
import com.peas.platform.framework.mybatisplus.repository.BaseRepository;
import com.peas.platform.module.icims.base.dict.adapter.repository.DictTypeRepository;
import com.peas.platform.module.icims.base.dict.adapter.repository.po.DictTypePo;
import com.peas.platform.module.icims.base.dict.domain.DictTypeDomain;
import com.peas.platform.module.icims.base.dict.dto.DictTypeDto;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Component
public class DictTypeDomainImpl extends BaseDomainImpl<DictTypeDto, DictTypePo> implements DictTypeDomain {

    @Resource
    private DictTypeRepository dictTypeRepository;

    @Override
    public BaseRepository<DictTypePo> getMapper() {
        return dictTypeRepository;
    }

    @Override
    public Class<? extends BaseRepository<DictTypePo>> getRepositoryClass() {
        return DictTypeRepository.class;
    }

    @Transactional
    @Override
    public int save(DictTypeDto dto) {
        int result = super.save(dto);
        this.checkRepetition("dictType", dto.getDictType());
        return result;
    }

    @Transactional
    @Override
    public int updateById(DictTypeDto dto) {
        int result = super.updateById(dto);
        this.checkRepetition("dictType", dto.getDictType());
        return result;
    }

}
